// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import "../static/common.css"
import "../static/base.css"
import "../static/tit.css"
import "../static/animate.css"
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import dataV from '@jiaminghi/data-view'
import dataVThem from '@/assets/data-v/config.js'

Vue.use(dataV)
Vue.mixin({
  data() {
    return {dataVThem}
  }
})

Vue.prototype.$EventBus = new Vue()


Vue.use(ElementUI);
Vue.config.errorHandler = function (err, vm, info) {
  // handle error
  // `info` 是 Vue 特定的错误信息，比如错误所在的生命周期钩子
  // 只在 2.2.0+ 可用
  console.debug(err, vm, info)
  // debugger;
}
const whiteList = [
  "/detail",
  "/discount",
  "/list",
  "/search",
  "/home",
  "/new",
  "/city",
  "/newdetail",
  "/login",
  "/404",
  "/shop",
  "/RemoveWatermark",
  "/video",
  "/gpt",
  "/introduce",
  "/SourcePage",
  "/TaskPage",
];
router.beforeEach((to, from, next) => {
  if (localStorage.getItem('user') == null) {
    if (whiteList.indexOf(to.path) !== -1) {
      next(true)
    } else {
      next('/login')
    }
    // next(true)
  } else {
    next(true)
  }
})


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})
